/**
 * @file EquationSolver.h
 * @brief 
 * @author htli (3180102114@zju.edu.cn)
 * @version 1.0
 * @date 2021-10-03
 * 
 * @copyright Copyright (c) 2021  linhuo2020
 * 
 */
#ifndef _PRO1_EQUATIONSOLVER_H_
#define _PRO1_EQUATIONSOLVER_H_

#include <iostream>
#include <cmath>
#include <string>
typedef double (*pFun)(double);
class EquationSolver
{
protected:
    double init[2] = {0, 1};
    pFun pf = NULL;
    pFun pdf = NULL;
    int max_iteration = 500;
    double tolerance = 1e-6;

public:
    EquationSolver(){};
    ~EquationSolver(){};
    EquationSolver(pFun _pf) { set_pf(_pf); };
    EquationSolver(pFun _pf, pFun _pdf)
    {
        set_pf(_pf);
        set_pdf(_pdf);
    };
    void set_max_iteration(const int _max) { max_iteration = _max; };
    const int get_max_iteration() { return max_iteration; };
    void set_tolerance(const double _tol) { tolerance = _tol; };
    const double get_tolerance() { return tolerance; };
    void set_init(const double _x1, const double _x2)
    {
        init[0] = _x1;
        init[1] = _x2;
    };
    void set_init(const double _x1) { set_init(_x1, 0); };
    void set_pf(const pFun _pf) { pf = _pf; };
    void set_pdf(const pFun _pdf) { pdf = _pdf; };
    virtual const double solve() = 0;
};

#else
//DO NOTHING
#endif